package edu.gdkm.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import edu.gdkm.pojo.User;
import org.springframework.stereotype.Repository;


@Repository
public interface UserDao {
    @Select("select * from user where id=#{id}")
    User findById(Integer id);

    @Select("select * from user")
    User[] selectAll(String username);

    @Insert("insert into user(username,password,email,phone,user_type,avatar,status,create_time,update_time) values(#{username},#{password},#{email},#{phone},#{userType},#{avatar},#{status},#{createTime},#{updateTime})")
    boolean save(User user);

    @Update("update user set username=#{username},password=#{password},email=#{email},phone=#{phone},user_type=#{userType},avatar=#{avatar},status=#{status},create_time=#{createTime},update_time=#{updateTime} where id=#{id}")
    boolean update(User user);

    @Delete("delete from user where id= #{id}")
    boolean delete(Integer id);

}
